function fctpop2001aFocus()
{
	document.getElementById("pop_name").focus();	
	return false;
}
function ajaxpop2001a_val(objForm)
{
	var sURL = "ajaxpop2001a_val.asp";	
	var sPop_name="";
	var sPop_poly ="";
	var sPop_geo_region="";
	var sPop_country="";
	
	var sPop_lat1_deg="";
	var iPop_lat1_deg=0;	
	var sPop_lat1_min="";
	var iPop_lat1_min=0;	
	var sPop_lat1_card="";
	
	var sPop_long1_deg="";
	var iPop_long1_deg=0;
	var sPop_long1_min="";
	var iPop_long1_min=0;
	var sPop_long1_card="";
	
	var sPop_ethnic_origin="";
	var sPop_sample="";
	var iPop_sample=0;
	var sPop_urban_rural="";		
	var sPop_family="";	
	var sPop_contributor="";
	var sPop_year="";
	var sPop_method="";	
	var sPop_method1="";
	var sPop_method2="";
	var sPop_method3="";
	var sPop_method4="";
	var sPop_method5="";
	var sPop_method6="";
	var sPop_method7="";
	var sPop_method8="";
	var sPop_source="";
	var sPop_details="";
	var sPop_notes="";
	var sPop_email="";
	
	//... Retrieving values ...//
	sPop_name = document.getElementById("pop_name").value;
	sPop_poly = document.getElementById("pop_poly").value;	
	sPop_geo_region = document.getElementById("pop_geo_region").value;
	sPop_country = document.getElementById("pop_country").value;
	
	//.... Latitude ...//
	sPop_lat1_deg = document.getElementById("pop_lat1_deg").value;
	if(sPop_lat1_deg!="")
	{
		iPop_lat1_deg = parseInt(sPop_lat1_deg);
		document.getElementById("pop_lat1_deg").value = iPop_lat1_deg;		
	}
	else
	{
		document.getElementById("pop_lat1_deg").value = 0;
	}	
	sPop_lat1_min = document.getElementById("pop_lat1_min").value;	
	if(sPop_lat1_deg!="")
	{
		iPop_lat1_min = parseInt(sPop_lat1_min);		
		document.getElementById("pop_lat1_min").value = iPop_lat1_min;
	}
	else
	{
		document.getElementById("pop_lat1_min").value = 0;
	}
	sPop_lat1_card = document.getElementById("pop_lat1_card").value;

	//.... Longitude ...//		
	sPop_long1_deg = document.getElementById("pop_long1_deg").value;
	if(sPop_long1_deg!="")
	{
		iPop_long1_deg = parseInt(sPop_long1_deg);
		document.getElementById("pop_long1_deg").value = iPop_long1_deg;
	}
	else
	{
		document.getElementById("pop_long1_deg").value = 0;
	}
	sPop_long1_min = document.getElementById("pop_long1_min").value;
	if(sPop_long1_min!="")
	{
		iPop_long1_min = parseInt(sPop_long1_min);
		document.getElementById("pop_long1_min").value = iPop_long1_min;	
	}
	else
	{
		document.getElementById("pop_long1_min").value = 0;
	}	
	sPop_long1_card = document.getElementById("pop_long1_card").value;	

	sPop_ethnic_origin = document.getElementById("pop_ethnic_origin").value;
	sPop_sample = document.getElementById("pop_sample").value;
	if(sPop_sample!="")
	{
		iPop_sample = parseInt(sPop_sample);
		document.getElementById("pop_sample").value = iPop_sample;
	}
	else
	{
		document.getElementById("pop_sample").value = 0;
	}
	sPop_ethnic_origin = document.getElementById("pop_ethnic_origin").value;	
	sPop_sample = document.getElementById("pop_sample").value;
	sPop_urban_rural = document.getElementById("pop_urban_rural").value;
	sPop_family = document.getElementById("pop_family").value;
	sPop_contributor = document.getElementById("pop_contributor").value;
	sPop_year = document.getElementById("pop_year").checked;
	sPop_method1 = document.getElementById("pop_ssp").checked;
	sPop_method2 = document.getElementById("pop_ssop").checked;
	sPop_method3 = document.getElementById("pop_sscp").checked;
	sPop_method4 = document.getElementById("pop_sbt").checked;
	sPop_method5 = document.getElementById("pop_seq").checked;
	sPop_method6 = document.getElementById("pop_rsca").checked;
	sPop_method7 = document.getElementById("pop_rflp").checked;
	sPop_method8 = document.getElementById("pop_oth").checked;
	sPop_method = ""
	sPop_method = sPop_method1 + sPop_method2 + sPop_method3 + sPop_method4;
	sPop_method = sPop_method + sPop_method5 + sPop_method6 + sPop_method7 + sPop_method8;	
	sPop_source = document.getElementById("pop_source").value;
	sPop_details = document.getElementById("pop_details").value;
	sPop_notes = document.getElementById("pop_notes").value;
	sPop_email = document.getElementById("pop_email").value;
	
	
	//===================//
	//... Validations ...//
	//===================//	
	if(sPop_name=='')
	{
			alert("Invalid Population Name. Please type a valid name.");
			document.getElementById("pop_name").focus();
			return false;
	}
	if(sPop_poly=='')
	{
			alert("Please select a Polymorphic Region.");
			document.getElementById("pop_poly").focus();
			return false;
	}
	if(sPop_geo_region=='')
	{
			alert("Please select a Geographic Region.");
			document.getElementById("pop_poly").focus();
			return false;
	}
	if(sPop_country=='')
	{
			alert("Please select a Country.");
			document.getElementById("pop_country").focus();
			return false;
	}
	if((sPop_lat1_deg != '')||(sPop_lat1_min != '')||(sPop_lat1_card != ''))
	{
		if((iPop_lat1_deg < 0)||(iPop_lat1_deg > 90))
		{
				alert("Invalid latitude. Degree values must be between 0-90");
				document.getElementById("pop_lat1_deg").focus();
				return false;
		}
		if((iPop_lat1_min < 0)||(iPop_lat1_min > 60))
		{
				alert("Invalid latitude. Minute values must be between 0-59");
				document.getElementById("pop_lat1_min").focus();
				return false;
		}
		if((sPop_lat1_card=='')&&((iPop_lat1_deg > 0)||(iPop_lat1_min > 0)))
		{
				alert("Please select a Cardinal Value for this latitude");
				document.getElementById("pop_lat1_card").focus();				
				return false;
		}
	}
	if((sPop_long1_deg != '')||(sPop_long1_min != '')||(sPop_long1_card != ''))
	{
		if((iPop_long1_deg < 0)||(iPop_long1_deg > 180))
		{
				alert("Invalid longitude. Degree values must be between 0-180");
				document.getElementById("pop_long1_deg").focus();
				return false;
		}
		if((iPop_long1_min < 0)||(iPop_long1_min > 60))
		{
				alert("Invalid longitude. Minute values must be between 0-59");
				document.getElementById("pop_long1_min").focus();
				return false;
		}
		if((sPop_long1_card=='')&&((iPop_long1_deg > 0)||(iPop_long1_min > 0)))
		{
				alert("Please select a Cardinal Value for this longitude");
				document.getElementById("pop_long1_card").focus();				
				return false;
		}
	}
	if(sPop_ethnic_origin=='')
	{
			alert("Please select a Ethnic Origin.");
			document.getElementById("pop_ethnic_origin").focus();
			return false;
	}
	if((sPop_sample=='')||(iPop_sample <= 0))
	{
			alert("Please type the sample size.");
			document.getElementById("pop_sample").focus();
			return false;
	}
	if(sPop_urban_rural=='')
	{
			alert("Please select Urban or Rural.");
			document.getElementById("pop_urban_rural").focus();
			return false;
	}
	if(sPop_family=='')
	{
			alert("Please select Family Background.");
			document.getElementById("pop_family").focus();
			return false;
	}	
	if(sPop_contributor=='')
	{
			alert("Please type contributor.");
			document.getElementById("pop_contributor").focus();
			return false;
	}	
	if(sPop_year=='')
	{
			alert("Please select a test date.");
			document.getElementById("pop_year").focus();
			return false;
	}
	if(sPop_method<=0)
	{
			alert("Please select a Method.");
			document.getElementById("pop_method").focus();
			return false;
	}
	if(sPop_source=='')
	{
			alert("Please select a Source.");
			document.getElementById("pop_source").focus();
			return false;
	}	
	if(sPop_email=='')
	{
			alert("Please type an e-mail address.");
			document.getElementById("pop_email").focus();
			return false;
	}
	
	//... Ajax to find possible names entered before ...//
	try
	{  
		 // Firefox, Opera 8.0+, Safari  
		 xmlHttp=new XMLHttpRequest();  
	 }
	 catch (e)
	 { 
		 // Internet Explorer  
		 try
		 {    
			   xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    
		 }
		 catch (e)
		 {    
			   try
			   {      
					 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");     
			   }
			   catch (e)
			   {      
					 //alert("Your browser does not support AJAX!");      
					 return false;      
			   }    
		 }  
	 }	   
	 xmlHttp.onreadystatechange=function()
	 {
		 if(xmlHttp.readyState==4)
		 {
			   sResponse = xmlHttp.responseText;
			   if(sResponse != "OK")
			   {
					alert(sResponse);
					document.getElementById("pop_name").focus();
					return false;
			   }
			   else
			   {
					objForm.submit();
					return true;
			   }
		 }
	 }
	 sURL = sURL + "?" + "pop_name=" + sPop_name;
	 xmlHttp.open("GET", sURL, true);
	 xmlHttp.send(null);
}
